//制作界面弹出警告

import { GameObject, getGameObjectById } from "../engine";
import { Behaviour } from "../engine/Behaviour";
import { TextRenderer } from "../engine/TextRenderer";
import { Display } from "./Display";

export class cookAlert extends Behaviour{
    //初始-1应为隐藏
    public alertFlag=0

    onStart(){
       
    }
    onTick(duringTime: number) {
        //取消提示框
        // if(this.alertFlag === 0){
        //     getGameObjectById("alert").getBehaviour(Display).IsActive = false
        // }
        function closeAlert(){
            setTimeout(
                function (){              
                getGameObjectById('alert').getBehaviour(Display).IsActive = false;    
            },1000);
            
        }    
            
        if(this.alertFlag === 1){
            getGameObjectById("alert").getBehaviour(Display).IsActive = true
            getGameObjectById("alertText").getBehaviour(TextRenderer).text = "已经放过油了！"
            closeAlert();
            this.alertFlag = 0;
        }
        if(this.alertFlag === 2){
            getGameObjectById("alert").getBehaviour(Display).IsActive = true
            getGameObjectById("alertText").getBehaviour(TextRenderer).text = "还没放油呐！"
            closeAlert();
            this.alertFlag = 0;
        }
        if(this.alertFlag === 3){
            getGameObjectById("alert").getBehaviour(Display).IsActive = true
            getGameObjectById("alertText").getBehaviour(TextRenderer).text = "还不能放该物品！"
            closeAlert();
            this.alertFlag = 0;
        }
        if(this.alertFlag === 4){
            getGameObjectById("alert").getBehaviour(Display).IsActive = true
            getGameObjectById("alertText").getBehaviour(TextRenderer).text = "还没切呐!"
            closeAlert();
            this.alertFlag = 0;
        }
    }
    

}